﻿
<!--高顺-->

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui/css/H-ui.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/css/H-ui.admin.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/lib/Hui-iconfont/1.0.8/iconfont.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/skin/default/skin.css}" id="skin"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/css/style.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/lib/laypage/1.2/skin/laypage.css}">
    <script type="text/javascript" th:src="@{/static/lib/jquery/1.9.1/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/layer/2.4/layer.js}"></script>
    <script type="text/javascript" th:src="@{/static/h-ui/js/H-ui.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/h-ui.admin/js/H-ui.admin.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/My97DatePicker/4.8/WdatePicker.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/datatables/1.10.0/jquery.dataTables.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/laypage/laypage.js}"></script>
    <script th:src="@{/static/lib/vue.min.js}"></script>

    <title>用户管理</title>
</head>
<body th:fragment="member-list">
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 申请入驻 <span
        class="c-gray en">&gt;</span> 申请入驻 <a class="btn btn-success radius r"
                                              style="line-height:1.6em;margin-top:3px"
                                              href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="text-c">
        <select name="xiala" id="xiala" onchange="queryByState(this.options[this.options.selectedIndex].value)">
            <option value="">请选择</option>
            <option value="" >查看所有</option>
            <option value="0" >待审核</option>
            <option value="1" >通过</option>
            <option value="2" >拒绝</option>
        </select>
        <input type="text" class="input-text" style="width:250px" placeholder="输入用户名" id="applyRealname">
        <button type="button" class="btn btn-success radius" id="search"><i class="Hui-iconfont">&#xe665;</i> 搜</button>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="1">共有数据：<strong id="shuju"></strong><span id="tiao"></span> 条</span></div>
    <div class="mt-20" id="app">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>

            <tr>
                <th scope="col" colspan="7">审核讲师入驻</th>
            </tr>
            <tr class="text-c">
                <th width="50" th:text="用户名"></th>
                <th width="70" th:text="联系方式"></th>
                <th width="75" th:text="申请讲师昵称"></th>
                <th width="60" th:text="姓名"></th>
                <th width="130" th:text="身份证件号"></th>
                <th width="80" th:text="执照"></th>
                <th width="100" th:text="自我简介"></th>
                <th width="100" th:text="申请文本"></th>
                <th width="100" th:text="审核状态"></th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr class="text-c" v-for="(item,index) in result">
                <td>{{item.applyName}}</td>
                <td>{{item.applyPhone}}</td>
                <td>{{item.applyTname}}</td>
                <td>{{item.applyRealname}}</td>
                <td>{{item.applyIdcard}}</td>
                <td><a @click="queryPic(item.applyId)"><img :src="item.applyLicense" width="50px" height="80px"></a>
                </td>
                <td>{{item.applyIntroduction}}</td>
                <td>{{item.applyContent}}</td>
                <td>{{item.applyState}}</td>
                <td class="f-14 td-manage" v-if="item.applyState=='待审核'">
                    <a style="text-decoration:none" class="ml-5" @click="attrafy(item.applyId)"
                       title="不通过"><i class="Hui-iconfont">&#xe6dd;</i></a>
                    <a style="text-decoration:none" @click="transit(item.applyId)" class="ml-5" title="通过"><i
                            class="Hui-iconfont">&#xe6e1;</i></a>
                </td>
                <td class="f-14 td-manage" v-else>
                    <a style="text-decoration:none" @click="delApplyById(item.applyId)" class="ml-5" title="删除"><i
                            class="Hui-iconfont">&#xe6e2;</i></a>
                </td>

            </tr>
            </tbody>
        </table>
        <br/>
        <div id="pagenav" class="text-c"></div>
    </div>
</div>
<script type="text/javascript" th:src="@{/static/layui/layui.js}"></script>
<script type="text/javascript">

    var pageNum;

    var app = new Vue({
        el: '#app',
        data: {
            result: []
        }
    });

    //点击查看大图
    function queryPic(id) {
        location.href = "/apply/queryPic?applyId=" + id
    }

    function queryByState() {
        getTeacherPageList();
    }

    /**
     * 高顺
     * 2019-12-15 12:01
     * 遍历出申请教师入驻的人
     */
    var getTeacherPageList = function (curr) {
        $.ajax({
            type: 'POST',
            dataType: 'JSON',
            url: '/apply/getApplyTeacher',
            data: {
                pageNum: curr || 1,
                pageSize: 3,
                state:$("#xiala option:checked").val(),
                applyRealname: $("#applyRealname").val()
            },
            success: function (result) {
                $("#tiao").html(result.count);
                app.result = result.apply;
                laypage({
                    cont: 'pagenav',
                    skin: '#008B8B',
                    pages: result.ct,
                    first: "首页",
                    last: "尾页",
                    curr: curr || 1,
                    jump: function (obj, first) {
                        if (!first) {
                            getTeacherPageList(obj.curr);
                        }
                    }
                });
            }
        });
    }
    getTeacherPageList();

    /**
     *高顺
     * 2019-12-15 1：03
     * 模糊搜索
     */
    $("#search").click(function () {
        getTeacherPageList();
    });


    //通过（高顺）
    var transit = function (id) {
        $.ajax({
            url: "/apply/updataApplyStateYes",
            dataType: 'json',
            type: 'post',
            data: {
                applyId: id
            },
            success: function (data) {
                if (data.msg == "ok") {
                    $.ajax({
                        url: '/apply/insertTeacherYes',
                        dataType: 'json',
                        type: 'post',
                        data: {
                            applyId: id
                        }, success: function () {
                            getTeacherPageList();
                        }
                    });
                    getTeacherPageList();
                } else {
                    alert("审核有误，请联系管理员！");
                }

            }
        })
    };

    /**
     * 删除（高顺）
     * @param id
     */
    var delApplyById = function (applyId) {
        //询问框
        var confirm = layer.confirm('您确定要删除么？', {
            btn: ['是', '否']
            //按钮
        }, function () {
            //是
            $.ajax({
                url:'/apply/delApplyById',
                dataType:'json',
                type:'post',
                data:{
                  applyId:applyId
                },
                success:function () {
                    getTeacherPageList();
                    layer.msg('已经成功删除记录', {icon: 5});
                }
            })

        }, function () {
            //否

        });
    };

    //拒绝（高顺）
    function attrafy(applyId) {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                type: 2,
                title: false,
                offset: '70px',
                closeBtn: false,
                skin: 'yourclass',
                // fix: false,
                // maxmin: true,
                shadeClose: true,
                // area: ['611px', '500px'],
                area: ['500px', '520px'],
                content: '/apply/toTeacherApplyCause/'+applyId,
                end: function () {
                    shuaxin();
                    getS();
                }
            });
        });
    }

</script>
</body>
</html>